find duplicate elements in array using brute force in java